package com.ssbc.dao;

import com.ssbc.bean.User;
import com.ssbc.dto.UserDTO;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

@Mapper
public interface UserDao{
//    @Select("select ru.* ,rt.* from role_user ru\n" +
//            "    left join role_user_role rur\n" +
//            "    left join role_type rt\n" +
//            "        on rur.role_id = rt.role_id\n" +
//            "        on ru.user_id = rur.user_id\n" +
//            "where username=#{username}")

    @Select("select role_user.*,role_type.role_name\n" +
            "from role_user,role_type,role_user_role\n" +
            "where username = 'a'\n" +
            "and role_user.user_id=role_user_role.user_id\n" +
            "and role_user_role.role_id=role_type.role_id")
    User getUserByUsername(String username);

//    @Results(
//            {
//                    @Result(id=true, column="user_id", property="user_id"),
//                    @Result(property="username", column="username"),
//                    @Result(property="password", column="password"),
//                    @Result(property="email", column="email"),
//                    @Result(property="roles", column="username",
//                        many=@Many(
//                                select="com.ssbc.dao.RoleDao.getRolesByUsername",
//                                fetchType= FetchType.LAZY
//                        ))
//            }
//    )

}
